package com.example.cloud.model.system;

import com.example.cloud.model.common.CommonModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by wangtao on 2018/3/4.
 */
@Entity(name = "sys_menu")
@Data
@EqualsAndHashCode(callSuper = false)
public class Menu extends CommonModel {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    // 菜单名称
    @Column(name = "title")
    private String title;
    // 菜单唯一标识
    @Column(name = "name")
    private String name;
    // 父节点
    @Column(name = "parent_id")
    private Long parentId;
    // 路由地址
    @Column(name = "path")
    private String path;
    // 图标
    @Column(name = "icon")
    private String icon;
    // 类型(1:菜单/2:按钮)
    @Column(name = "type")
    private int type;
    // 排序
    @Column(name = "sort")
    private int sort;
    // 菜单是否显示(1：是 2：否)
    @Column(name = "is_show", columnDefinition = "INT DEFAULT 1")
    private int isShow;
    // 是否选中
    @Transient
    private boolean checked = false;
    // 子菜单集合
    @Transient
    private List<Menu> children = new ArrayList<Menu>();
    // 账户编号
    @Column(name = "account_id")
    private Long accountId;
}
